package second;

import java.awt.Toolkit;

import javax.swing.JFrame;

public class Center {
	private static Toolkit toolkit = Toolkit.getDefaultToolkit();
	private static int height = toolkit.getScreenSize().height;
	private static int width = toolkit.getScreenSize().width;
	
	public static int getX(int x) {
		return (width-x)/2;
	}
	
	public static int getY(int y) {
		return (height-y)/2;
	}
	
	public static void setToScreenCenter(JFrame frame) {
		
		frame.setVisible(true);
		frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		frame.setAlwaysOnTop(true);
		frame.setBounds(Center.getX(300), Center.getY(250), 300, 250);	
		
	}
}
